home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 6.7 KB | 205 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPrstng.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWPRSTNG_H
- #include "FWPrstng.h"
- #endif
-
- #ifndef FWPARTNG_H
- #include "FWPartng.h"
- #endif
-
- #ifndef FWFRMING_H
- #include "FWFrming.h"
- #endif
-
- #ifndef FWSLCING_H
- #include "FWSlcing.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWPXYFRM_H
- #include "FWPxyFrm.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fw_embedding
- #endif
-
- FW_DEFINE_CLASS_M1(FW_CEmbeddingPresentation, FW_CPresentation)
-
- //========================================================================================
- // class FW_CEmbeddingPresentation
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingPresentation::FW_CEmbeddingPresentation
- //----------------------------------------------------------------------------------------
-
- FW_CEmbeddingPresentation::FW_CEmbeddingPresentation(Environment *ev,
- FW_CEmbeddingPart* thePart,
- FW_CEmbeddingSelection* selection,
- ODTypeToken presentationType,
- FW_Boolean sameViewTypeForEmbeddedFrames) :
- FW_CPresentation(ev, thePart, selection, presentationType, sameViewTypeForEmbeddedFrames)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingPresentation::~FW_CEmbeddingPresentation
- //----------------------------------------------------------------------------------------
-
- FW_CEmbeddingPresentation::~FW_CEmbeddingPresentation()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingPresentation::Embed
- //----------------------------------------------------------------------------------------
-
- FW_DECLARE_THROW_POINT (FW_CEmbeddingPresentation_Embed);
-
- void FW_CEmbeddingPresentation::Embed(Environment *ev,
- ODPart *odEmbeddedPart,
- ODFrame* odEmbeddedFrame, // Might be null
- FW_MProxy* proxy,
- ODShape* frameShape,
- ODTypeToken viewType,
- ODTypeToken presentationType,
- ODID frameGroupID,
- FW_Boolean subFrame)
- {
- /* Exception Handling
- If an exception is thrown while we are partway through creating frames then we
- have destroy all previously created frames.
- */
- FW_ASSERT(odEmbeddedPart);
- FW_ASSERT(frameShape);
- FW_ASSERT(proxy);
-
- ODFrame* passedInFrame = NULL;
- ODFrame* sourceFrame = NULL;
- ODFrame* newEmbeddedFrame = NULL;
-
- // ----- Create an embedded frame for each of my display frame -----
- FW_TRY { // loop protection
- FW_CPresentationFrameIterator ite(this);
- for (FW_CEmbeddingFrame* embeddingFrame = (FW_CEmbeddingFrame*)ite.First(); ite.IsNotComplete(); embeddingFrame = (FW_CEmbeddingFrame*)ite.Next())
- {
- FW_CAcquiredODShape aqItsShape(frameShape->Copy(ev));
-
- FW_CAcquiredProxyFrame aqProxyFrame;
-
- // ----- Create the frame -----
- FW_Boolean isEmbeddedFrame = FALSE;
- if (odEmbeddedFrame != NULL)
- {
- FW_CAcquiredODFrame aqContainingFrame = odEmbeddedFrame->AcquireContainingFrame(ev);
- isEmbeddedFrame = (aqContainingFrame == embeddingFrame->GetODFrame(ev));
- }
-
- if (isEmbeddedFrame)
- {
- odEmbeddedFrame->SetViewType(ev, viewType);
- odEmbeddedFrame->SetPresentation(ev, presentationType == NULL ? GetPart(ev)->GetSession(ev)->Tokenize(ev, kODPresDefault) : presentationType);
- odEmbeddedFrame->SetFrameGroup(ev, frameGroupID);
- odEmbeddedFrame->SetSubframe(ev, subFrame);
-
- newEmbeddedFrame = odEmbeddedFrame;
- passedInFrame = odEmbeddedFrame;
- odEmbeddedFrame = NULL; // We used it. Next time around we want to create a new frame
-
- aqProxyFrame = new FW_CProxyFrame(ev, (FW_CEmbeddingPart*)GetPart(ev), proxy, embeddingFrame, newEmbeddedFrame);
-
- // Change the frame shape after we have a proxyFrame (only if neccessary)
- FW_CAcquiredODShape aqFrameShape = newEmbeddedFrame->AcquireFrameShape(ev, NULL);
- if (!aqFrameShape->IsSameAs(ev, aqItsShape))
- newEmbeddedFrame->ChangeFrameShape(ev, aqItsShape, NULL);
- }
- else
- {
- aqProxyFrame = embeddingFrame->PrivCreateEmbeddedFrame(ev,
- embeddingFrame->IsPersistent(ev) ? kODFrameObject : kODNonPersistentFrameObject,
- odEmbeddedPart,
- proxy,
- aqItsShape,
- NULL,
- viewType,
- presentationType,
- frameGroupID,
- FALSE,
- subFrame);
- newEmbeddedFrame = aqProxyFrame->GetFrame(ev);
- }
-
- FW_TRY
- {
- // ----- Attach source frames if needed -----
- // If we are creating two or more frames at the same time then this tells the embedded part
- // that those frames are supposed to display the same content.
- if (sourceFrame)
- odEmbeddedPart->AttachSourceFrame(ev, newEmbeddedFrame, sourceFrame);
- sourceFrame = newEmbeddedFrame;
-
- // ----- Create its facets -----
- // We have to make sure not to leave a dangling frame if this fails
- FW_CHECK_THROW_POINT (FW_CEmbeddingPresentation_Embed);
- // XXX if isEmbedded frame then we shouldn't destroy it (since we didn't create it)
- embeddingFrame->PrivCreateEmbeddedFacets(ev, proxy, aqProxyFrame);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING () {
- // aqProxyFrame has increased the refount of the proxy frame; this will bother
- // the PrivRemoveEmbeddedFrame code, which asserts it to be 1 at some point.
- FW_CProxyFrame * proxyFrame = aqProxyFrame;
- aqProxyFrame = (FW_CProxyFrame*) kODNULL;
- embeddingFrame->PrivRemoveEmbeddedFrame (ev, proxyFrame);
- FW_THROW_SAME ();
- }
- FW_CATCH_END
- }
- } // FW_TRY loop protection
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING () {
- // Work in reverse to clean up everything from previous passes through the loop.
- // That is if we completed two loops and failed partway through loop 3, assume that loop 3
- // was cleaned up properly (in try/catch block above) and undo loops 1 and 2.
- // XXX Should we release passedInFrame since we didn't create it?
- // XXX not implemented
- FW_THROW_SAME ();
- }
- FW_CATCH_END
-
- // ----- If we haven't use odEmbeddedFrame there is a problem -----
- FW_ASSERT(odEmbeddedFrame == NULL);
- }
-